feat: auto handle dialogs during script evaluation#1792
Closed
Lightning00Blade wants to merge 10 commits intomainfrom
Closed
feat: auto handle dialogs during script evaluation#1792Lightning00Blade wants to merge 10 commits intomainfrom
Lightning00Blade wants to merge 10 commits intomainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Lightning00Blade
commented
Apr 1, 2026
Lightning00Blade
commented
Apr 1, 2026
Lightning00Blade
commented
Apr 2, 2026
Added a new option `dialog` to `waitForEventsAfterAction` to automatically handle dialogs that trigger during execution. We hardcode it to `'accept'` for the `evaluate_script` tool so that `alert()` or `confirm()` don't block and timeout script evaluation. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Moved `dialogHandler` inside the `if (options?.dialog)` block to avoid unnecessarily declaring it when it is not needed. Also imported the correct `Dialog` type from Puppeteer. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Removed the unnecessary type cast by typing `#page` properly as `Page`. Casts to `CdpPage` are now isolated to where `_client()` is required. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Reverted the type of `#page` back to `CdpPage` and handled the `Dialog` compatibility issue locally using `@ts-expect-error` instead of a cast. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
bdfc5aa to
95d377b
Compare
Replaced `alert()` with `setTimeout(() => alert(), 10)` in `script.test.ts` to prevent headless Chromium deadlocks during `evaluate` in CI environments. Additionally added `.catch(logger)` when resolving dialog actions to prevent unhandled promise rejections if the dialog closes too quickly or fails. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Removed `test_dialog.js`, `test_dialog.mjs`, and `test_dialog2.mjs` which were accidentally left in the workspace and caused `npm run check-format` to fail. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Updated README.md formatting to match latest requirements to fix `check-format` CI job. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #919 by automatically accepts dialogs, when actions happen due to Script exection.